<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script type="text/javascript">
    // 补全代码
    // function Human(name) {
    //   this.name = name
    //   this.kingdom = 'animal'
    //   this.color = ['yellow', 'white', 'brown', 'black']
    // }

    // 指向实例对象
    // Human.prototype.getName = function () {
    //   return this.name
    // }
    // // 指回原来的对象
    // Human.prototype.constructor = Human

    // function Chinese(name, age) {
    //   Human.call(this, name)
    //   this.color = 'yellow'
    //   this.age = age
    // }
    // // 使得Chinese的构造函数继承Human的构造函数
    // // Chinese.prototype = new Human()
    // Chinese.prototype = Object.create(Human.prototype)
    // Chinese.prototype.constructor = Chinese
    // Chinese.prototype.getAge = function () {
    //   return this.age
    // }

    // const fn = new Chinese('jerry', 3)
    // console.log(fn)
    // console.log(fn.getName())
    // console.log(fn.getAge())

    function Human(name, sex) {
      this.name = name
      this.sex = sex
      this.kingdom = 'animal'
    }

    Human.prototype.getName = function () {
      console.log(this.name)
    }
    Human.prototype.constructor = Human

    function Chinese(name, age, sex) {
      Human.call(this, name, sex)
      this.age = age
    }

    Chinese.prototype = Object.create(Human.prototype)
    Chinese.prototype.constructor = Chinese

    Chinese.prototype.sing = function () {
      console.log('sing the song')
    }

    const people = new Chinese('jerry', '27', '女')

    console.log(people)


  </script>
</body>

</html>